package com.eeds.controller.pc;

import com.eeds.base.BaseController;
import com.eeds.common.model.BaseWrapper;
import com.eeds.common.model.PageInfo;
import com.eeds.interceptor.NeedAuth;
import com.eeds.model.proclamation.req.*;
import com.eeds.model.proclamation.res.ResGetProclamationListVO;
import com.eeds.model.proclamation.res.ResGetProclamationVO;
import com.eeds.model.proclamation.res.ResUpdateProclamationVO;
import com.eeds.model.user.res.ResGetUserInfoListVO;
import com.eeds.service.proclamation.ProclamationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@Api(value = "公告接口", description = "公告接口")
@RequestMapping("pc/proclamation/")
public class ProclamationController extends BaseController {


    @Autowired
    private ProclamationService proclamationService;

    /**
     * description:添加公告
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/addProclamation", method = RequestMethod.POST)
    @ApiOperation("添加公告")
    public BaseWrapper<Integer> addProclamation(@Valid @ModelAttribute ReqAddProclamationVO reqAddProclamationVO){
        Integer result = proclamationService.addProclamation(reqAddProclamationVO);
        return new BaseWrapper<>(result);
    }


    /**
     * description:获取公告信息列表
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth
    @RequestMapping(value = "/getProclamationList", method = RequestMethod.GET)
    @ApiOperation("获取公告信息列表")
    public BaseWrapper<PageInfo<ResGetProclamationListVO>> getUserInfoList(
            @Valid @ModelAttribute ReqGetProclamationListVO reqGetProclamationListVO){
        PageInfo<ResGetProclamationListVO> result =
                proclamationService.getProclamationList(reqGetProclamationListVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:获取公告信息
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth
    @RequestMapping(value = "/getProclamation", method = RequestMethod.GET)
    @ApiOperation("获取公告信息")
    public BaseWrapper<ResGetProclamationVO> getProclamation(
            @Valid @ModelAttribute ReqGetProclamationVO reqGetProclamationVO){
        ResGetProclamationVO result =
                proclamationService.getProclamation(reqGetProclamationVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:修改公告信息
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/updateProclamation", method = RequestMethod.POST)
    @ApiOperation("修改公告信息")
    public BaseWrapper<Integer> updateProclamation(
            @Valid @ModelAttribute ReqUpdateProclamationVO reqUpdateProclamationVO){
        Integer result =
                proclamationService.updateProclamation(reqUpdateProclamationVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:删除公告信息
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/delProclamation", method = RequestMethod.POST)
    @ApiOperation("删除公告信息")
    public BaseWrapper<Integer> delProclamation(
            @Valid @ModelAttribute ReqDelProclamationVO reqDelProclamationVO){
        Integer result = proclamationService.delProclamation(reqDelProclamationVO);
        return new BaseWrapper<>(result);
    }

}
